<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Consultas</title>
<script type="text/javascript" src="js/OGC.js"></script>
<script type="text/javascript">
	function mostrarConsulta1(){
		document.getElementById("textArea1").value = 
			'<wfs:GetFeature service="WFS" version="1.1.0"\n'+
			'  xmlns:topp="http://www.openplans.org/topp"\n'+
			'	  xmlns:wfs="http://www.opengis.net/wfs"\n'+
			'	  xmlns:ogc="http://www.opengis.net/ogc"\n'+
			'	  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\n'+
			'	  xsi:schemaLocation="http://www.opengis.net/wfs\n'+
			'	                     http://schemas.opengis.net/wfs/1.1.0/wfs.xsd">\n'+
			'	  <wfs:Query typeName="topp:states">\n'+
			'	    <ogc:Filter>\n'+
			'	       <ogc:FeatureId fid="states.3"/>\n'+
			'	    </ogc:Filter>\n'+
			'	    </wfs:Query>\n'+
			'</wfs:GetFeature> ';
			
			var featureId = new FeatureId("states.3");
			var filter = new Filter(featureId);
			var query = new Query("topp:states",filter);
			var getFeature = new GetFeature("1.1.0",query);
			document.getElementById("textArea2").value = getFeature.toString(); 
	}
	
	function mostrarConsulta2(){
		document.getElementById("textArea1").value =
			'<wfs:GetFeature service="WFS" version="1.1.0" \n'+
			'	  xmlns:topp="http://www.openplans.org/topp" \n'+
			'	  xmlns:wfs="http://www.opengis.net/wfs" \n'+
			'	  xmlns:ogc="http://www.opengis.net/ogc" \n'+
			'	  xmlns:gml="http://www.opengis.net/gml" \n'+
			'	  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" \n'+
			'	  xsi:schemaLocation="http://www.opengis.net/wfs \n'+
			'	                      http://schemas.opengis.net/wfs/1.1.0/wfs.xsd"> \n'+
			'	  <wfs:Query typeName="topp:states"> \n'+
			'	    <wfs:PropertyName>topp:STATE_NAME</wfs:PropertyName> \n'+
			'	    <wfs:PropertyName>topp:PERSONS</wfs:PropertyName> \n'+
			'	    <ogc:Filter> \n'+
			'	      <ogc:BBOX> \n'+
			'	        <ogc:PropertyName>the_geom</ogc:PropertyName> \n'+
			'	        <gml:Envelope srsName="http://www.opengis.net/gml/srs/epsg.xml#4326"> \n'+
			'	           <gml:lowerCorner>-75.102613 40.212597</gml:lowerCorner> \n'+
			'	           <gml:upperCorner>-72.361859 41.512517</gml:upperCorner> \n'+
			'	        </gml:Envelope> \n'+
			'	      </ogc:BBOX> \n'+
			'	   </ogc:Filter> \n'+
			'	  </wfs:Query> \n'+
			'	</wfs:GetFeature>';
		
		var coord1 = new Coordinate(-75.102613,40.212597);
		var coord2 = new Coordinate(-72.361859,41.512517);
		var envelope = new Envelope("4326",coord1,coord2);
		var bbox = new BBOX("the_geom",envelope);
		var filter = new Filter(bbox);
		var properties = [new PropertyName("topp:STATE_NAME"),new PropertyName("topp:PERSONS")];
		var query = new Query("topp:states",filter,properties);
		var getFeature = new GetFeature("1.1.0",query);
		document.getElementById("textArea2").value = getFeature.toString();
	}
	
	function mostrarConsulta3(){
		document.getElementById("textArea1").value =
			'<wfs:GetFeature service="WFS" version="1.1.0" \n'+
			'	  xmlns:topp="http://www.openplans.org/topp" \n'+
			'	  xmlns:wfs="http://www.opengis.net/wfs" \n'+
			'	  xmlns:ogc="http://www.opengis.net/ogc" \n'+
			'	  xmlns:gml="http://www.opengis.net/gml" \n'+
			'	  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" \n'+
			'	  xsi:schemaLocation="http://www.opengis.net/wfs \n'+
			'	                      http://schemas.opengis.net/wfs/1.1.0/wfs.xsd"> \n'+
			'	  <wfs:Query typeName="topp:states"> \n'+
			'	  <wfs:PropertyName>topp:STATE_NAME</wfs:PropertyName> \n'+ 
			'	  <wfs:PropertyName>topp:LAND_KM</wfs:PropertyName>  \n'+
			'	  <wfs:PropertyName>topp:the_geom</wfs:PropertyName>  \n'+
			'	<ogc:Filter> \n'+
			'	<ogc:PropertyIsBetween> \n'+
			'	<ogc:PropertyName>topp:LAND_KM</ogc:PropertyName> \n'+
			'	<ogc:LowerBoundary><ogc:Literal>100000</ogc:Literal></ogc:LowerBoundary> \n'+
			'	<ogc:UpperBoundary><ogc:Literal>150000</ogc:Literal></ogc:UpperBoundary> \n'+
			'	</ogc:PropertyIsBetween> \n'+
			'	</ogc:Filter> \n'+
			'	  </wfs:Query> \n'+
			'	</wfs:GetFeature>';
		
		var isBetween = new PropertyIsBetween("topp:LAND_KM",new Literal(100000),new Literal(150000));
		var filter = new Filter(isBetween);
		var properties = [new PropertyName("topp:STATE_NAME"),new PropertyName("topp:LAND_KM"),new PropertyName("topp:the_geom")];
		var query = new Query("topp:states",filter,properties);
		var getFeature = new GetFeature("1.1.0",query);
		document.getElementById("textArea2").value = getFeature.toString();
	}
	
	function mostrarConsulta4(){
		document.getElementById("textArea1").value =
			'<wfs:GetFeature service="WFS" version="1.1.0" \n'+
			'	  xmlns:topp="http://www.openplans.org/topp" \n'+
			'	  xmlns:wfs="http://www.opengis.net/wfs" \n'+
			'	  xmlns="http://www.opengis.net/ogc" \n'+
			'	  xmlns:gml="http://www.opengis.net/gml" \n'+
			'	  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" \n'+
			'	  xsi:schemaLocation="http://www.opengis.net/wfs \n'+
			'	                      http://schemas.opengis.net/wfs/1.1.0/wfs.xsd"> \n'+
			'	  <wfs:Query typeName="topp:states"> \n'+
			'	    <Filter> \n'+
			'	      <Intersects> \n'+
			'	        <PropertyName>the_geom</PropertyName> \n'+
			'	          <gml:Point srsName="http://www.opengis.net/gml/srs/epsg.xml#4326"> \n'+
			'	            <gml:coordinates>-74.817265,40.5296504</gml:coordinates> \n'+
			'	          </gml:Point> \n'+
			'	        </Intersects> \n'+
			'	      </Filter> \n'+
			'	  </wfs:Query> \n'+
			'	</wfs:GetFeature>';
		
		var point = new Point("4326",new Coordinate(-74.817265,40.5296504));
		var intersects = new Intersects("the_geom",point);
		var filter = new Filter(intersects);
		var query = new Query("topp:states",filter);
		var getFeature = new GetFeature("1.1.0",query);
		document.getElementById("textArea2").value = getFeature.toString();
	}
	
	function mostrarConsulta5(){
		document.getElementById("textArea1").value = 
			'<wfs:GetFeature service="WFS" version="1.1.0" \n'+
			'	  xmlns:topp="http://www.openplans.org/topp" \n'+
			'	  xmlns:wfs="http://www.opengis.net/wfs" \n'+
			'	  xmlns:ogc="http://www.opengis.net/ogc" \n'+
			'	  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" \n'+
			'	  xsi:schemaLocation="http://www.opengis.net/wfs \n'+
			'	                      http://schemas.opengis.net/wfs/1.0.0/WFS-basic.xsd"> \n'+
			'	  <wfs:Query typeName="topp:states"> \n'+
			'	    <ogc:Filter> \n'+
			'	      <ogc:PropertyIsGreaterThan> \n'+
			'	        <ogc:Div> \n'+
			'	            <ogc:PropertyName>MANUAL</ogc:PropertyName> \n'+
			'	            <ogc:PropertyName>WORKERS</ogc:PropertyName> \n'+
			'	        </ogc:Div> \n'+
			'	         <ogc:Literal>0.25</ogc:Literal> \n'+
			'	    </ogc:PropertyIsGreaterThan> \n'+
			'	    </ogc:Filter> \n'+
			'	    </wfs:Query> \n'+
			'	</wfs:GetFeature>';
		
		var literal = new Literal(0.25);
		var div = new Div(new PropertyName("MANUAL"),new PropertyName("WORKERS"));
		var isGraterThan = new PropertyIsGreaterThan(div,literal);
		var filter = new Filter(isGraterThan);
		var query = new Query("topp:states",filter);
		var getFeature = new GetFeature("1.1.0",query);
		document.getElementById("textArea2").value = getFeature.toString();
	}
</script>
</head>
<body>
	<table>
		<tr>
			<td>
				<input type="button" value="Consulta 1" onclick="mostrarConsulta1()" />
				<input type="button" value="Consulta 2" onclick="mostrarConsulta2()" />
				<input type="button" value="Consulta 3" onclick="mostrarConsulta3()" />
				<input type="button" value="Consulta 4" onclick="mostrarConsulta4()" />
				<input type="button" value="Consulta 5" onclick="mostrarConsulta5()" />
			</td>
		</tr>
		<tr>
			<td><textarea rows="30" cols="65" id="textArea1"></textarea>
				<textarea rows="30" cols="65" id="textArea2"></textarea>
			</td>
		</tr>
	</table>
</body>
</html>